package javafx.demo.animation;

import javafx.animation.FadeTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
 * 渐变效果
 * 
 * @author flyfox
 * @date 2014年10月23日
 */
public class TestFadeTransition extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		final Rectangle rect1 = new Rectangle(10, 10, 100, 100);
		rect1.setArcHeight(20);
		rect1.setArcWidth(20);
		rect1.setFill(Color.RED);
		
		FadeTransition ft = new FadeTransition(Duration.millis(3000), rect1);
		ft.setFromValue(1.0);
		ft.setToValue(0.1);
		ft.setCycleCount(Timeline.INDEFINITE);
		ft.setAutoReverse(true);
		ft.play();
		
		BorderPane outerRoot = new BorderPane();
		outerRoot.setCenter(rect1);

		Scene scene = new Scene(outerRoot, 600, 500);

		stage.setTitle("Hello World!");
		stage.setScene(scene);
		stage.show();

	}

	public static void main(String[] args) {
		launch(args);
	}
}
